//
//  MPHomeDetailViewController.m
//  sanguosha
//
//  Created by caiqilin on 2017/7/5.
//  Copyright © 2017年 caiqilin. All rights reserved.
//

#import "MPHomeDetailViewController.h"
#import "MPHomeDetailTopView.h"
#import "MPWebViewController.h"
@interface MPHomeDetailViewController ()
@property (nonatomic, strong) NSArray *detailArr;

@end

@implementation MPHomeDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = _homeDetailArr[@"menuName"];
    _detailArr = _homeDetailArr[@"topMenu"];
    MPHomeDetailTopView *topView = [MPHomeDetailTopView homeDetailTopView];
    topView.iconImageView.image = [UIImage imageNamed:_homeDetailArr[@"menuImage"]];
    topView.contentTitle.text = _homeDetailArr[@"menuName"];
    topView.frame = CGRectMake(0, 0, SCREEN_WIDTH, 180);
    self.tableView.tableHeaderView = topView;
    self.tableView.backgroundColor = [Util stringTOColor:@"#f2f2f2"];
    self.tableView.tableFooterView = [[UIView alloc] init];
}


#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _detailArr.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *ID = @"status";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;

//    if(){
//        
//    }
    cell.textLabel.text = _detailArr[indexPath.row];
    
    
    return cell;
}

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
    cell.layoutMargins = UIEdgeInsetsZero;
    cell.separatorInset = UIEdgeInsetsZero;
    cell.preservesSuperviewLayoutMargins = NO;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSString *title = _detailArr[indexPath.row];
    MPWebViewController *web = [[MPWebViewController alloc] init];
    web.menuTitle = title;
    [self.navigationController pushViewController:web animated:YES];
}
@end
